package com.dys.controller;

import com.dys.common.ResponseResult;
import com.dys.entity.LoginBody;
import com.dys.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 疾风
 * @ClassName: LoginHasCodeController
 * @Description: 带有验证码的登录控制器
 * @CreateDate: 2024/12/18
 * @Version: v1.0.0
 */
@RestController
@RequestMapping(value = "/user")
public class LoginHasCodeController {

    @Autowired
    private LoginService loginService;

    @PostMapping(value = "/loginByCode")
    public ResponseResult<Map<String, Object>> login(@RequestBody LoginBody loginBody) {
        // 生成token令牌
        String token = loginService.login(loginBody.getUserName(), loginBody.getPassword(), loginBody.getCode(), loginBody
                .getUuid());
        Map<String, Object> map = new HashMap<>(1);
        map.put("token", token);
        return new ResponseResult<>(200, "登录成功-校验验证码", map);
    }
}
